package com.asp.alumnisystem.presenter;

import com.asp.alumnisystem.app.App;
import com.asp.alumnisystem.base.BaseBean;
import com.asp.alumnisystem.base.BasePresenter;
import com.asp.alumnisystem.base.IView;
import com.asp.alumnisystem.net.RetrofitManager;
import com.asp.alumnisystem.utils.StringUtils;

import io.reactivex.Observable;

/**
 * 发布帖子的Presenter
 */
public class PublishPresenter extends BasePresenter<String, Boolean> {

    public PublishPresenter(IView view) {
        super(view);
    }

    @Override
    protected boolean filter(String s) {
        if (StringUtils.isNull(s)){
            throw new RuntimeException("内容不能为空");
        }
        return true;
    }

    @Override
    protected Observable<BaseBean<Boolean>> requestNet(String s) {
        return RetrofitManager.getApi().publish(App.getApp().getUserId(), s);
    }

}
